package com.xuchaotong.utils;

public class StringDemo {
    private transient String initStr;
    private String temp;
    private final String changeable;
    private final int iAble = 0;

    public StringDemo() {
//        this.changeable = "changed";
        this.changeable = "中国";
    }

    public static void main(String[] args) {
        StringDemo instance = new StringDemo();
//        System.out.println(instance.changeable.charAt(1));
//        instance.test();
//        instance.test1();
//        instance.test2();
//        instance.test3();
        System.out.println(2 + "3");
    }


    public void test() {
        String s = initStr;
        if (s == null) {
            initStr = new String("init");
        }

        System.out.println(initStr.toString());
        System.out.println(s.toString());
    }

    public void test1() {
        String s = "init";
        String s1 = new String("init");
        String s2 = "init";

        System.out.println(s == s1);
        System.out.println(s.equals(s1));
        System.out.println(s == s2);

    }

    public void test2() {
        String value1 = "abc";
        String value2 = "a" + "b" + "c";
        String value3 = "a" + new String("bc");


        System.out.println(value1 == value2);
        System.out.println(value2 == "abc");
        System.out.println(value3 == value1);
    }

    public void test3() {
        temp = initStr;
        if (temp == null) {
            initStr = new String("init");
        }

        System.out.println(temp);
    }

    public void test4(){
//        changeable = "can't not changed";
//        iAble++;
    }

}
